import { scene } from './utils/init'
import * as THREE from 'three'
import { guiChangeColor } from './utils/gui'

function initBase() {
  const geometry = new THREE.SphereGeometry(1, 32, 16)

  const textureLoader = new THREE.TextureLoader()
  const texture = textureLoader.load('texture/one/basecolor.jpg')
  texture.colorSpace = THREE.SRGBColorSpace
  // 1. 引入透明度材质
  const transTextureLoader = new THREE.TextureLoader()
  const transTexture = transTextureLoader.load('texture/one/opacity.jpg')


  const material = new THREE.MeshBasicMaterial({ 
    map: texture,
    alphaMap: transTexture, // 2. 附上透明度贴图
    transparent: true // 3. 开启透明度贴图
  })

  const mesh = new THREE.Mesh(geometry, material)
  guiChangeColor(texture)
  scene.add(mesh)
}

initBase()